<template>
	<view >
		<view>
			<view style="margin-top:30rpx">
				<view v-for="(item,index) in abnormalArr" :key="index">
					<view class="row indexTeacher1" @click="abnormalIndexSkip(item)">
						<view>
							{{item.patrolType | showPatrolType}}
						</view>
						<view>
							{{item.patrolTime}}
						</view>
						<view>
							详情
						</view>
					</view>
				</view>
			</view>
			<view class="logoSty"></view>
		</view>
		
	</view>
</template>

<script>
	import topCom from '../component/topCom.vue'
	import bottomCom from '../component/bottom.vue'
	import headTitle from '../component/btnHeadeCom.vue'
	export default {
		data() {
			return {
				Attbottoms: [{
						name: 'home',
						icon: 'iconfont icon-yonghutongji',
						text: "首页",
						path: '/pages/index/index'
					},

					{
						name: 'maintenance',
						icon: 'iconfont icon-shezhi',
						text: "退出",
						path: '/pages/index/login'
					},
				],
				userName: '',
				topName: '待处理异常巡查',
				id: '',
				abnormalArr: [],

			}
		},
		components: {
			topCom,
			bottomCom,
			headTitle
		},
		filters: {
			showPatrolType(type) {
				
				if (type == "2") {
					return "早操巡查";
				} else if (type == "3") {
					return "课堂巡查";
				} else if (type == "4") {
					return "午休巡查";
				} else if (type == "5") {
					return "晚自习巡查";
				} else if (type == "6") {
					return "课间巡查";
				} else if (type == "1") {
					return "宿舍巡查";
				}
			}
		},
		onShow() {
			var that = this
			uni.getStorage({
				key: "loginName",
				success: (res) => {
					that.userName = res.data
				}
			})
			uni.getStorage({
				key: "loginId",
				success: (res) => {
					that.id = res.data
				}
			})

			var loginId = uni.getStorageSync("loginId");

			this.$api.dormitory.findToDo(loginId).then(res => {
				// console.log(res)
				this.abnormalArr = res.data;
				// console.log(this.abnormalArr, 121)
			})
		},
		methods: {
			abnormalIndexSkip(item) {
				var obj = JSON.stringify(item);
				if (item.patrolType == '3') {
					uni.navigateTo({
						url: '/pages/abnormal/classroomViolation?obj=' + obj,
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				}
				if (item.patrolType == '2') {
					uni.navigateTo({
						url: '/pages/abnormal/admissionAndMorningExercises?obj=' + obj,
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				}
				if (item.patrolType == '4') {
					uni.navigateTo({
						url: '/pages/abnormal/lunchBreakPatrol?obj=' + obj,
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				}
				if (item.patrolType == '6') {
					uni.navigateTo({
						url: '/pages/abnormal/classroomPatrol?obj=' + obj,
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				}
				if (item.patrolType == '1') {
					uni.navigateTo({
						url: '/pages/abnormal/supervisorPatrol?obj=' + obj,
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				}
				if (item.patrolType == '5') {
					uni.navigateTo({
						url: '/pages/abnormal/nightPatrol?obj=' + obj,
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				}
			}
		},

	}
</script>

<style>
	.row {
		display: flex;
		justify-content: space-around;
		padding: 0 30rpx;
	}

	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.indexTeacher2 {
		margin: auto;
		margin-top: 40upx;
		width: 605upx;
		height: 76upx;
		display: flex;
		justify-content: space-between;
		background-image: url(https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/T-5.png);
		background-size: 100%;
		color: white;
		padding-top: 30upx;
		font-size: 30rpx;
		/* opacity: 0.8; */
	}

	.indexTeacher0 {
		margin: auto;
		margin-top: 40upx;
		width: 605upx;
		height: 76upx;
		display: flex;
		justify-content: space-between;
		background-image: url(https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/T-6.png);
		background-size: 100%;
		color: white;
		padding-top: 30upx;
		font-size: 30rpx;
		/* opacity: 0.8; */
	}

	.indexTeacher1 {
		border-bottom: #e9e9ee solid 1rpx;
		margin: auto;
		/* margin-top: 40upx; */
		width: 605upx;
		height: 76upx;
		display: flex;
		justify-content: space-between;
		color: gray;
		padding-top: 30upx;
		font-size: 30rpx;
		/* opacity: 0.8; */
	}
</style>